package BehavioralMode.state.elevator;

import BehavioralMode.state.elevator.elevatorState.CloseState;
import BehavioralMode.state.elevator.elevatorState.OpenState;
import BehavioralMode.state.elevator.elevatorState.RunState;
import BehavioralMode.state.elevator.elevatorState.StopState;

/**
 * 环境类
 */
public class Context {
    public final static ElevatorState openState = new OpenState();
    public final static ElevatorState closeState = new CloseState();
    public final static ElevatorState runState = new RunState();
    public final static ElevatorState stopState = new StopState();


    private ElevatorState elevatorState;

    public Context() {
        this.elevatorState = Context.openState;
        this.elevatorState.setContext(this);
    }

    public void setElevatorState(ElevatorState elevatorState){
        this.elevatorState = elevatorState;
        this.elevatorState.setContext(this);
    }

    public ElevatorState getElevatorState() {
        return elevatorState;
    }

    public void open(){
        elevatorState.open();
    }

    public void close(){
        elevatorState.close();
    }

    public void stop(){
        elevatorState.stop();
    }

    public void run(){
        elevatorState.run();
    }



}
